// ValidationAspects
// Written by Mike Saunders
// Released under Microsoft Public License (Ms-PL)
using NUnit.Framework;
using ValidationAspects.Exceptions;
using ValidationAspects.Factories;
using ValidationAspects.Sdk;

namespace TestValidationAspects.Factories
{
	[TestFixture]
    public class TestNotNullOrWhiteSpace
	{
		[Test]
		[ExpectedException(typeof(UnsupportedValidationException))]
		public void Test_CreateValidator_throws_for_unsupported_type()
		{
            new NotNullOrWhiteSpace().Create<object>();
		}

		[Test]
        public void Test_NotNullOrWhiteSpace()
		{
            IValidator<string> validator = new NotNullOrWhiteSpace().Create<string>();

            Test.Throws<ValidateNotNullOrWhiteSpaceException>(() => validator.Invoke(null, new MockValidationContext()), new ValidateNotNullOrWhiteSpaceException().Message);
            Test.Throws<ValidateNotNullOrWhiteSpaceException>(() => validator.Invoke(string.Empty, new MockValidationContext()), new ValidateNotNullOrWhiteSpaceException().Message);
			validator.Invoke("text", new MockValidationContext());
		}
	}
}